package com.realshare.frame.component.quartz.base;

import org.apache.commons.lang3.StringUtils;
import org.springframework.scheduling.quartz.QuartzJobBean;

import java.io.Serializable;

/**
 * ${DESCRIPTION}
 * author leisure
 * email 15075107120@139.com
 * create 2018-11-23 下午 5:54
 * modify 2018-11-23 下午 5:54
 **/
public abstract class BaseScheduler extends QuartzJobBean implements Serializable {

    private boolean isTriggerByServiceStart = true;//是否在服务启动后立即执行一次任务
    private String description = "";//任务描述

    private BaseScheduler() {
    }

    /**
     * @param isTriggerByServiceStart 是否在服务启动后立即执行一次任务
     */
    public BaseScheduler(boolean isTriggerByServiceStart) {
        this.isTriggerByServiceStart = isTriggerByServiceStart;
        this.description = setDescription();
        initInfo();
    }

    private void initInfo() {
        description = StringUtils.isBlank(description) ? "系统自动生成任务信息" : description;
    }

    public abstract String setDescription();

    public boolean isTriggerByServiceStart() {
        return isTriggerByServiceStart;
    }

    public String getDescription() {
        return description;
    }

}